<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAttachmentTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attachment', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->unsignedInteger('member_id')->default('0')->comment('会员ID，后期扩展');
            $table->string('name', 100)->default('')->comment('文件名称');
            $table->string('ext', 20)->default('')->comment('文件扩展名');
            $table->unsignedTinyInteger('type')->default('0')->comment('【备用】文件类型，数据字典');
            $table->integer('size')->default(0)->comment('文件大小（KIB）');
            $table->string('path')->default('')->comment('文件地址');
            $table->string('thumb_path')->default('')->comment('缩略图地址，文件名_thumb.扩展名');
            $table->integer('downloads')->default(1)->comment('下载次数');
            $table->unsignedInteger('sort')->default('999')->comment('排序位置');
            $table->unsignedTinyInteger('status')->default('1')->comment('发布状态，0未发布，1已发布 ，数据字典');
            $table->string('model')->default('')->comment('模型');
            $table->string('model_table', 100)->default('')->comment('模型表名');
            $table->integer('model_id')->default(0)->comment('模型ID');
            $table->string('model_attachment_field', 50)->default('')->comment('模型附件上传字段');
            $table->unsignedTinyInteger('store_type')->default('1')->comment('存储类型：1本地 2阿里云oss');
            $table->string('description')->default('')->comment('描述');
            $table->unsignedInteger('created_user_id')->default('0')->comment('管理员ID');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('更新时间');
            $table->softDeletes()->comment('删除时间');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('attachment');
    }
}
